#pragma once

#include "directxincludes\d3d9.h"
#include "directxincludes\d3dx9.h"

#include "MapController.h"

// include the Direct3D Library files
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")
#pragma comment (lib, "winmm.lib")
#pragma comment (lib, "user32.lib")

enum game { MAIN, PLAY, WIN } ;

#define SPRITE_SIZE	32
#define MAX_SPRITES	13

#define SCREEN_WIDTH	1024
#define SCREEN_HEIGHT	600

class DXGraphics
{
private:
	// global declarations
	LPDIRECT3D9 d3d;    // the pointer to our Direct3D interface
	LPDIRECT3DDEVICE9 d3ddev;    // the pointer to the device class
	LPD3DXSPRITE d3dspt;    // the pointer to our Direct3D Sprite interface
	LPD3DXFONT d3dfnt_game ;	//the pointer to the Direct3D Font Interface
	LPD3DXFONT d3dfnt_menu ;	//the pointer to the Direct3D Font Interface

	//tracks the current amount of sprites loaded
	int count ;

	//controls where the sprites are drawn and where they are centered at
	D3DXMATRIX spriteTranslation ;
	D3DXVECTOR3 center ;

	//textbox with buffer
	RECT textbox ;
	char buffer[30] ;

	//holds the position of the cursor
	POINT mousePos ;

	//holds a copy of the client window
	HWND m_hWnd ;

	// sprite declarations
	LPDIRECT3DTEXTURE9 m_sprArr[MAX_SPRITES] ;

public:
	DXGraphics( ) ;
	~DXGraphics( ) ;

	// function prototypes
	LPDIRECT3DTEXTURE9 loadSprite( char * filename ) ;
	POINT getMousePos() { return mousePos ; }
	void initD3D(HWND hWnd) ;    // sets up and initializes Direct3D
	void Update( ) ;			//updates each frame
	void createBox( int a_width, int a_height, int a_offset ) ;
	LPCSTR getCharBuffer( int a_mines, int a_flags ) ;
	void render_frame( Map * a_map, int state ) ;    // renders a single frame
	void cleanD3D(void) ;    // closes Direct3D and releases memory
} ;

extern DXGraphics* gDGraphics ;